﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Linq;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
public partial class Industry : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            selectIndustry();
            
        }
    }

    private void selectIndustry()
    {
        var industry = new DealesDataContext();
        var query = industry.Industry_Return();
        RadGrid1.DataSource = query;
        RadGrid1.DataBind();
    }
    protected void RadGrid1_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        var IndustryID = (long)((GridDataItem)e.Item).GetDataKeyValue("IndustryID");
        var industry = new DealesDataContext();
        var query = industry.Delete_Industry(IndustryID);
        selectIndustry();
    }
    protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        var editableItem = ((GridEditableItem)e.Item);
        var industry = new DealesDataContext();
        RadTextBox txtIndustry = e.Item.FindControl("txtIndustry") as RadTextBox;
        var query = industry.Insert_Industry(txtIndustry.Text);
    }
    protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        var editableItem = ((GridEditableItem)e.Item);
        var IndustryID = (long)editableItem.GetDataKeyValue("IndustryID");
        var industry = new DealesDataContext();
        RadTextBox txtIndustry = e.Item.FindControl("txtIndustry") as RadTextBox;
        var query = industry.Update_Industry(IndustryID, Convert.ToString(txtIndustry.Text));
    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        var industry = new DealesDataContext();
        var query = industry.Industry_Return();
        RadGrid1.DataSource = query;
    }
}
